<template>
    <div class="programModify">
        <el-form 
            ref="ruleForm" 
            label-width="100px"
            :model="ruleForm">
            <el-form-item label="小程序名称">
                <el-select v-model="ruleForm.myappname" placeholder="请选择小程序名称">
                    <el-option :label=myappname value='' ></el-option>
                    <el-option :label=item.appname :value=item.appname v-for="(item,index) in options" :key="index">{{item.appname}}</el-option>
                </el-select>
            </el-form-item>
            <el-form-item label="模块名称" prop="type">
                <el-input v-model="ruleForm.type"  :placeholder="type"></el-input>
            </el-form-item>



            <el-upload
                class="upload-demo"
                action="https://www.yyjpai.com/index/operate/uploadsImg"
                :on-success=handleAvatarSuccess
                name="file"
                list-type="picture">
                <el-button size="small" type="primary">点击上传</el-button>
                <div slot="tip" class="el-upload__tip">图片大小为1M之内</div>
            </el-upload>




            <el-upload
                class="upload-demo"
                action="https://www.yyjpai.com/index/operate/uploadsImg"
                :on-success=handleAvatarSuccess1
                name="file"
                list-type="picture">
                <el-button size="small" type="primary">点击上传</el-button>
                <div slot="tip" class="el-upload__tip">二维码大小为1M之内</div>
            </el-upload>



            <el-form-item label="产品名称">
                <el-input v-model="ruleForm.name" :placeholder="name"></el-input>
            </el-form-item>
            
            <el-form-item label="APPID">
                <el-input v-model="ruleForm.appid"></el-input>
            </el-form-item>
            <el-form-item label="跳转路径">
                <el-input v-model="ruleForm.pages"></el-input>
            </el-form-item>
            <el-form-item label="携带参数">
                <el-input v-model="ruleForm.param"></el-input>
            </el-form-item>
            <el-form-item label="游戏人数">
                <el-input v-model="ruleForm.person"></el-input>
            </el-form-item>
            <el-form-item label="排序">
                <el-input v-model="ruleForm.sort"></el-input>
            </el-form-item>
        </el-form>
       <el-button @click="submitForm('ruleForm')" size="medium" class="addSubimit">提交</el-button>
    </div>
    
</template>
<script>
import { AddData,getChannel } from '@/assets/js'
export default {
    data(){
        return {
            options:[],
            ruleForm:{
                type:this.type,//模块名称
                name:this.name,//文字
                logo:this.logo,//图片
                poster:this.poster,//二维码
                myappname:this.myappname,//小程序名称
                appid:this.appid,//小程序APPID
                pages:this.pages,//小程序跳转路径
                param:this.param,//小程序跳转路径
                person:this.person,//游戏人数
                sort:this.sort//排序
            }
        }
    },
    mounted:function(){
        getChannel(this)
    },
    methods:{
        handleAvatarSuccess(res, file) {//上传成功之后
            this.ruleForm.logo = file.response.data.logo
        },
        handleAvatarSuccess1(res, file) {//上传成功之后
            this.ruleForm.poster = file.response.data.logo
        },
        submitForm:function(e){
            let data = {
                id:this.id,
                type:this.ruleForm.type==''?this.type:this.ruleForm.type,
                name:this.ruleForm.name==''?this.name:this.ruleForm.name,
                myappname:this.ruleForm.myappname==''?this.myappname:this.ruleForm.myappname,
                total_person:this.ruleForm.person==''?this.person:this.ruleForm.person,
                appid:this.ruleForm.appid==''?this.appid:this.ruleForm.appid,
                pages:this.ruleForm.pages,
                param:this.ruleForm.param==''?this.param:this.ruleForm.param,
                sort:this.ruleForm.sort==''?this.sort:this.ruleForm.sort,
                logo:this.ruleForm.logo==''?this.logo:this.ruleForm.logo,
                poster:this.ruleForm.poster==''?this.poster:this.ruleForm.poster
            }
            AddData(this,e,data,'jump_program/editJumpProgram')
        }
    },
    props:['id','type',"name","myappname","appid","pages","param","sort","logo","person","poster"]
}
</script>